(function($){
	$.fn.FocusImg = function(Objs){
		var defaults = {
			jqBox:"#FocusImg",
			box_w:1000,
			Interval:5000,
			bun:true,
			btn:true,
			autoplay:true,
			num_text:false
		}
		var Objs = $.extend(defaults,Objs);
		this.each(function(){
			var that=$(this);
			var count,p=0,num=0,num_html,time;
			if(Objs.box_w=="auto") $(that).css({"width":"100%"});
			var jqPic=$(Objs.jqBox).find(".pic");
			count=$(jqPic).find("li").length-1;
			if(Objs.btn==true){
			num_html="<div class='num'>";
			if(Objs.num_text==true){
				for(var t=0;t<=count;t++){num_html+="<a href='#'>"+$(jqPic).find("li").eq(t).attr("num_text")+"</a>"}
			}
			else{
				for(var t=0;t<=count;t++){num_html+="<a href='#'></a>"}	
				}
			num_html+="</div>";
			$(that).prepend(num_html);
			var jqNum=$(Objs.jqBox).find(".num");
			$(jqNum).find("a").eq(0).addClass("current");
			$(jqNum).find("a").bind({
				click:function(){
					clearInterval(time);
					num=$(this).index()-1;
					showimg();
					time=setInterval(showimg,Objs.Interval);
					return false;}
					});
			}
			$(jqPic).find("li").eq(0).css({"z-index":101});
			
			function showimg(){
			num++;
			if(num>count)num=0;
			if(num<0) num=count;
			p=$(jqNum).find("a.current").index();
			$(jqNum).find("a").removeClass("current");
			$(jqNum).find("a").eq(num).addClass("current");
			$(jqPic).find("li").css({opacity:"0","z-index":100});
			$(jqPic).find("li").eq(num).css({"z-index":101});
			$(jqPic).find("li").eq(p).css({opacity:"1"});
			$(jqPic).find("li").eq(p).stop(true,false).animate({opacity:"0"},1000); 
			$(jqPic).find("li").eq(num).stop(true,false).animate({opacity:"1"},1000); 
			}
			
			if(Objs.autoplay==true){time=setInterval(showimg,Objs.Interval);}
	
	if(Objs.bun==true){
		var bun_html="<a class='bun lbun' href='#'></a><a class='bun rbun' href='#'></a>";
		$(that).prepend(bun_html);
		$(that).find(".lbun").bind({
			click:function(){
				clearInterval(time);
				showimg();
				time=setInterval(showimg,Objs.Interval);
				return false;}
				});

	$(that).find(".rbun").bind({
		click:function(){
			clearInterval(time);
			num=num-2;
			showimg();
			time=setInterval(showimg,Objs.Interval);
			return false;}
			});
		}

		});
	};
})(jQuery);